<!DOCTYPE HTML>
<html>
<head>
    <title><%= __('views.equipmentRepair')%></title>
    <% include common/meta.ejs %>
    <% include common/public.ejs %>
    <style>
        .weui_cell_primary select {
            height: 24px;line-height: 24px;padding-left: 0;
        }
    </style>
</head>
<body ontouchstart="">
<form id="reservedForm">
    <div class="weui_cells weui_cells_form">
        <input type="hidden" name="issueUser" value="<%= userData.id %>">
        <input type="hidden" name="name" value="<%= userData.name %>">
        <input type="hidden" name="userImg" value="<%= userData.headimgurl %>">
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label"><%= __('views.repairEquipment')%></label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <select class="weui_select"
                        emptyOption="false"
                        name="device.id">
                    <% if(data && data.deviceList) {for(var i = 0;i < data.deviceList.length;i++) { %>
                        <% if(data.deviceList[i].status!=2){ %>
                        <option value="<%= data.deviceList[i].id %>"><%= data.deviceList[i].name %></option>
                        <%}%>
                    <% }} %>
                </select>
            </div>
        </div>
<!---->
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label"><%= __('views.contactPerson')%></label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="weui_input" type="text" name="contactName" placeholder="<%= __('views.personContact')%>"
                       value="<%= userData.name %>">
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label"><%= __('views.cellphoneNumber')%></label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="weui_input" type="tel" name="contactPhone" placeholder="<%= __('views.cellphoneNumber')%>"
                       value="<%= userData.phone %>">
            </div>
        </div>
        <div class="weui_cell">
            <div class="weui_cell_hd"><label class="weui_label"><%= __('views.detailedAddress')%></label></div>
            <div class="weui_cell_bd weui_cell_primary">
                <input class="weui_input" type="text" name="address" placeholder="<%= __('views.detailedAddress')%>">
            </div>
        </div>
    </div>

    <div class="weui_cells_title"><%= __('views.detailedDescription')%></div>
    <div class="weui_cells weui_cells_form">
        <div class="weui_cell">
            <div class="weui_cell_bd weui_cell_primary">
                <textarea class="weui_textarea" name="remark" placeholder="<%= __('views.describeProblem')%>" rows="3"></textarea>
            </div>
        </div>
    </div>
</form>
<div style="text-align: center;width: 100%;padding: 20px 0;">
    <button style="margin-top: 20px;margin-bottom: 10px;" id="repairSubmit" class="weui_btn weui_btn_warn"><%= __('views.equipmentCall')%></button>
    <a href="repairList?openId=<%= session.openId %>" style="color: #3ab6b4;font-size: 0.7rem;margin-bottom: 10px;"><%= __('views.lookMyRevisionHistory')%></a>
</div>
<% include common/footer.ejs %>
<script>
    $("#repairSubmit").click(function () {
        $.confirm({
            title: Dolphin.i18n.get("views.confirmationRepairEquipment"),
            text: Dolphin.i18n.get("views.reportThisEquipment"),
            onOK: function () {
                $.showLoading();
                var data = Dolphin.form.getValue("#reservedForm");
                console.log(data);
                Dolphin.ajax({
                    url: '<%= global.config.contextPath == '/' ? '' : global.config.contextPath %>/api/fcca1aa0e7554b2bb871d3a1b8a7df36',
                    type: 'put',
                    forceUrl: 'true',
                    data: Dolphin.json2string(data),
                    onSuccess: function () {
                        location.href = "repairList";
                    },
                    onComplete: function () {
                        $.hideLoading();
                    }
                })
            },
            onCancel: function () {
            }
        });
    });
</script>
</body>
</html>